import { createRouter, createWebHashHistory } from 'vue-router'
import { ElMessage } from 'element-plus'

const routes = [
  {
    path: '/',
    redirect: '/Welcome',
  },
  {
    path: '/welcome',
    name: '欢迎页面',
    component: () => import('@/views/welcome.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

/**
 * 前置路由守卫
 */
router.beforeEach((to, from, next) => {
  // console.log(to, from)
  // ElMessage({ type: 'success', message: '前置路由守卫', duration: 1000, showClose: true })
  next()
})

/**
 * 后置路由守卫
 */
router.afterEach(() =>{
  // ...
})

export default router
